{{--前台详情页--}}
@extends('default.layouts.part_time_managePublic')
@section('title', '发布兼职')
{{--兼职详情页css--}}
@section('headcss')
    <meta name="keywords" content="{{Site::get('homekeywords')}}">
    <meta name="description" content="{{Site::get('homedescription')}}">
    @parent
    <link rel="stylesheet" type="text/css" href="{{asset('/default/css/company/welcome.css')}}">
    <link rel="stylesheet" href="{{asset('/default/css/part_time/manage.css')}}">

    <link rel="stylesheet" href="{{asset('/vendor/jedate/skin/jedate.css')}}">

@endsection

{{--主体内容--}}
@section('content')
    {{--职位信息及侧边下载框--}}
    <div class="main">
        <div class="wrapper">
            <div class="asideNav">
                <ul>
                    @include('default.layouts.part_time_public_left')
                </ul>
            </div>
            {{--新增兼职--}}
            <div class="newPartTime">
                <h2><span>新增兼职</span></h2>
                <form action="{{url('company/pt_store')}}" method="post" onSubmit="return false"
                      name="partTimeCreateForm"
                      id="partTimeCreateForm">
                    {!! csrf_field() !!}
                    {{--输出全部错误信息--}}
                    @if(count($errors)>0)
                        <div class="errors" style=" margin-top: 15px">
                            <ul>
                                @if(is_object($errors))
                                    @foreach($errors->all() as $error)
                                        <li><span>{{$error}}</span></li>
                                    @endforeach
                                @else
                                    <li><span>{{$errors}}</span></li>
                                @endif
                            </ul>
                        </div>
                    @endif
                    <ul>
                        <li class="list l_name">
                            <span class="left">兼职名称</span>
                            <i class="mustFillIn">*</i>
                            <input id="title" name="title" type="text" value="{{old('title')}}" placeholder="请输入兼职名称"
                                   tip="请输入兼职名称">
                            <div class="errinfo"></div>
                        </li>
                        <li class="list l_type">
                            <span class="left">兼职类型</span>
                            <i class="mustFillIn">*</i>
                            <input id="partTimeType" name="type_id" type="hidden" value="{{old('type_id')}}"
                                   tip="请选择兼职类型">
                            <div id="partTimeType_select" class="select">
                                <span><a></a></span><i></i></div>
                            <div class="errinfo"></div>
                        </li>
                        <li class="list l_period">
                            <span class="left">工作周期</span>
                            <i class="mustFillIn">*</i>
                            <div class="showTime" id="showTime">
                                <input class="datainp wicon timeput" id="inputTimeStart" name="time_start"
                                       type="text" placeholder="开始日期" value="{{old('time_start')}}" readonly>
                            </div>
                            <strong>-</strong>
                            <div class="showTime" id="showTime">
                                <input class="datainp wicon timeput" id="inputTimeEnd" name="time_end" type="text"
                                       placeholder="结束日期" value="{{old('time_end')}}" readonly>
                            </div>
                            <div>
                                <input id="longTerm" name="long_term" type="hidden"
                                       value="{{old('long_term')?old('long_term'):0}}">
                                <input id="longTermValue" class="longTerm" type="checkbox">
                                <label for="longTermValue">长期兼职</label>
                            </div>
                        </li>
                        <li class="list l_workTime">
                            <span class="left">工作时间</span>
                            <i class="mustFillIn">*</i>
                            <table>
                                <tr class="title">
                                    <td></td>
                                    <td>星期一</td>
                                    <td>星期二</td>
                                    <td>星期三</td>
                                    <td>星期四</td>
                                    <td>星期五</td>
                                    <td>星期六</td>
                                    <td>星期七</td>
                                <tr>
                                    <td class="workTime">上午</td>
                                    <td>
                                        <input class="numValue" id="num1" name="num[1]" type="hidden"
                                               value="{{old('num')[1]?old('num')[1]:0}}">
                                        <input class="num" data-name="num1" type="checkbox">
                                    </td>
                                    <td>
                                        <input class="numValue" id="num4" name="num[4]" type="hidden"
                                               value="{{old('num')[4]?old('num')[4]:0}}">
                                        <input class="num" data-name="num4" type="checkbox">
                                    </td>
                                    <td>
                                        <input class="numValue" id="num7" name="num[7]" type="hidden"
                                               value="{{old('num')[7]?old('num')[7]:0}}">
                                        <input class="num" data-name="num7" type="checkbox">
                                    </td>
                                    <td>
                                        <input class="numValue" id="num10" name="num[10]" type="hidden"
                                               value="{{old('num')[10]?old('num')[10]:0}}">
                                        <input class="num" data-name="num10" type="checkbox">
                                    </td>
                                    <td>
                                        <input class="numValue" id="num13" name="num[13]" type="hidden"
                                               value="{{old('num')[13]?old('num')[13]:0}}">
                                        <input class="num" data-name="num13" type="checkbox">
                                    </td>
                                    <td>
                                        <input class="numValue" id="num16" name="num[16]" type="hidden"
                                               value="{{old('num')[16]?old('num')[16]:0}}">
                                        <input class="num" data-name="num16" type="checkbox">
                                    </td>
                                    <td>
                                        <input class="numValue" id="num19" name="num[19]" type="hidden"
                                               value="{{old('num')[19]?old('num')[19]:0}}">
                                        <input class="num" data-name="num19" type="checkbox">
                                    </td>
                                </tr>
                                <tr>
                                    <td class="workTime">下午</td>
                                    <td>
                                        <input class="numValue" id="num2" name="num[2]" type="hidden"
                                               value="{{old('num')[2]?old('num')[2]:0}}">
                                        <input class="num" data-name="num2" type="checkbox">
                                    </td>
                                    <td>
                                        <input class="numValue" id="num5" name="num[5]" type="hidden"
                                               value="{{old('num')[5]?old('num')[5]:0}}">
                                        <input class="num" data-name="num5" type="checkbox">
                                    </td>
                                    <td>
                                        <input class="numValue" id="num8" name="num[8]" type="hidden"
                                               value="{{old('num')[8]?old('num')[8]:0}}">
                                        <input class="num" data-name="num8" type="checkbox">
                                    </td>
                                    <td>
                                        <input class="numValue" id="num11" name="num[11]" type="hidden"
                                               value="{{old('num')[11]?old('num')[11]:0}}">
                                        <input class="num" data-name="num11" type="checkbox">
                                    </td>
                                    <td>
                                        <input class="numValue" id="num14" name="num[14]" type="hidden"
                                               value="{{old('num')[14]?old('num')[14]:0}}">
                                        <input class="num" data-name="num14" type="checkbox">
                                    </td>
                                    <td>
                                        <input class="numValue" id="num17" name="num[17]" type="hidden"
                                               value="{{old('num')[17]?old('num')[17]:0}}">
                                        <input class="num" data-name="num17" type="checkbox">
                                    </td>
                                    <td>
                                        <input class="numValue" id="num20" name="num[20]" type="hidden"
                                               value="{{old('num')[20]?old('num')[20]:0}}">
                                        <input class="num" data-name="num20" type="checkbox">
                                    </td>
                                <tr>
                                    <td class="workTime">晚上</td>
                                    <td>
                                        <input class="numValue" id="num3" name="num[3]" type="hidden"
                                               value="{{old('num')[3]?old('num')[3]:0}}">
                                        <input class="num" data-name="num3" type="checkbox">
                                    </td>
                                    <td>
                                        <input class="numValue" id="num6" name="num[6]" type="hidden"
                                               value="{{old('num')[6]?old('num')[6]:0}}">
                                        <input class="num" data-name="num6" type="checkbox">
                                    </td>
                                    <td>
                                        <input class="numValue" id="num9" name="num[9]" type="hidden"
                                               value="{{old('num')[9]?old('num')[9]:0}}">
                                        <input class="num" data-name="num9" type="checkbox">
                                    </td>
                                    <td>
                                        <input class="numValue" id="num12" name="num[12]" type="hidden"
                                               value="{{old('num')[12]?old('num')[12]:0}}">
                                        <input class="num" data-name="num12" type="checkbox">
                                    </td>
                                    <td>
                                        <input class="numValue" id="num15" name="num[15]" type="hidden"
                                               value="{{old('num')[15]?old('num')[15]:0}}">
                                        <input class="num" data-name="num15" type="checkbox">
                                    </td>
                                    <td>
                                        <input class="numValue" id="num18" name="num[18]" type="hidden"
                                               value="{{old('num')[18]?old('num')[18]:0}}">
                                        <input class="num" data-name="num18" type="checkbox">
                                    </td>
                                    <td>
                                        <input class="numValue" id="num21" name="num[21]" type="hidden"
                                               value="{{old('num')[21]?old('num')[21]:0}}">
                                        <input class="num" data-name="num21" type="checkbox">
                                    </td>
                                </tr>
                            </table>
                            <button type="button" id="allCheck">全选</button>
                        </li>
                        <li class="list l_recruit">
                            <span class="left">招聘人数</span><i class="mustFillIn">*</i>
                            <input id="need_num" type="text" name="need_num" value="{{old('need_num')}}"
                                   placeholder="0代表若干" tip="请输入人数，0代表若干"><span>人</span>
                            <div class="errinfo"></div>
                        </li>
                        <li class="list l_gender">
                            <span class="left">性别要求</span>
                            <i class="mustFillIn">*</i>
                            <input id="sex" name="sex" type="hidden" value="{{old('sex')}}" tip="请选择性别要求">
                            <div id="sex_select" class="select"><span><a></a></span><i></i></div>
                            <div class="errinfo"></div>
                        </li>
                        <li class="list l_education">
                            <span class="left">学历要求</span>
                            <i class="mustFillIn">*</i>
                            <input id="education" name="education" type="hidden" value="{{old('education')}}"
                                   tip="请选择学历要求">
                            <div id="education_select" class="select"><span><a></a></span><i></i></div>
                            <div class="errinfo"></div>
                        </li>
                        <li class="list l_salary">
                            <span class="left">薪资待遇</span>
                            <i class="mustFillIn">*</i>
                            <input id="salary_price" type="text" name="salary_price" value="{{old('salary_price')}}"
                                   placeholder="请输入薪资" tip="请输入薪资">
                            <label for="salary"></label>
                            <input id="salary_unit" type="hidden" name="salary_unit" value="{{old('salary_unit')}}"
                                   tip="请选择薪资单位">
                            <div id="salary_unit_select" class="select">
                                <span><a></a></span><i></i>
                            </div>
                            <input id="salary_method" type="hidden" name="salary_method"
                                   value="{{old('salary_method')}}" tip="请选择薪资结算类型">
                            <div id="salary_method_select" class="select">
                                <span><a></a></span><i></i>
                            </div>
                            <div class="errinfo"></div>
                        </li>
                        <li class="list l_workArea">
                            <span class="left">工作区域</span><i class="mustFillIn">*</i>
                            <input name="city_id" type="hidden" id="city_id" value="{{$webAreaCode or old('city_id')}}">
                            <div class="jList" onClick="workplaceInput2('','type')">
                                <input type="text" name="web_area_name" class="input" id="workplace" value="{{$webAreaName or old('web_area_name')}}" readonly style="cursor: text" placeholder="请选择工作地区"/>
                                 <i></i>
                            </div>
                            <div class="errinfo"></div>
                        </li>
                        <li class="list l_address">
                            <span class="left">详细地址</span><i class="mustFillIn">*</i>
                            <input id="address" type="text" name="address"
                                   value="@if(strlen(old('address')) > 0){{old('address')}}@elseif(isset($lastInfo->address)){{$lastInfo->address}}@else{!! '' !!}@endif" placeholder="请输入详细地址" tip="请输入详细地址">
                            <label for="address"></label>
                            <div class="setMapCss">
                                <input name="position" type="hidden" id="position"
                                       value="{{old('position')}}"/>
                                <input name="coordinate_address" type="hidden" id="coordinate_address"
                                       value="{{old('coordinate_address')}}"/>
                                <input name="longitude" type="hidden" id="longitude"
                                       value="{{old('longitude')}}"/>
                                <input name="latitude" type="hidden" id="latitude"
                                       value="{{old('latitude')}}"/>
                                <span class="setmap"><a id="setMap">设置坐标</a></span>
                                @if(old('coordinate_address')?old('coordinate_address'):'')
                                    <span class="noset" id="noset"
                                          style="color: #999">已设置地图位置：{{old('coordinate_address')}}</span>
                                @else
                                    <span class="noset" id="noset">未设置</span>
                                @endif
                            </div>
                            <div class="errinfo"></div>
                        </li>
                        <li class="list l_workCont">
                            <span class="left">工作内容</span>
                            <i class="mustFillIn">*</i>
                            <textarea id="content" name="content" tip="请输入工作内容">{{old('content')}}</textarea>
                            <div class="errinfo"></div>
                        </li>
                        <li class="list l_contact">
                            <span class="left">联系人</span>
                            <i class="mustFillIn">*</i>
                            <input id="contacts" type="text" name="contacts"
                                   value="@if(strlen(old('contacts')) > 0){{old('contacts')}}@elseif(isset($lastInfo->contacts)){{$lastInfo->contacts}}@else{!! '' !!}@endif"
                                   placeholder="请输入联系人" tip="请输入联系人">
                            <div class="errinfo"></div>
                        </li>
                        <li class="list l_phoneNum">
                            <span class="left">手机号码</span>
                            <i class="mustFillIn">&nbsp;</i>
                            <input id="mobile" type="text" name="mobile"
                                   value="@if(strlen(old('mobile')) > 0){{old('mobile')}}@elseif(isset($lastInfo->mobile)){{$lastInfo->mobile}}@else{!! '' !!}@endif"
                                   placeholder="请输入手机号" tip="请输入手机号">
                            <div class="errinfo"></div>
                        </li>
                        <li class="list l_number">
                            <span class="left">固定电话</span>
                            <i class="mustFillIn">&nbsp;</i>
                            <input class="area_code" id="area_code" type="text" name="area_code" placeholder="区号"
                                   value="@if(strlen(old('area_code')) > 0){{old('area_code')}}@elseif(isset($lastInfo->phone_split[0])){{$lastInfo->phone_split[0]}}@else{!! '' !!}@endif">
                            <strong>-</strong>
                            <input class="phone" id="phone" type="text" name="phone" placeholder="固定电话"
                                   value="@if(strlen(old('phone')) > 0){{old('phone')}}@elseif(isset($lastInfo->phone_split[1])){{$lastInfo->phone_split[1]}}@else{!! '' !!}@endif">
                            <strong>-</strong>
                            <input class="ext" id="ext" type="text" name="ext" placeholder="分机(选填)"
                                   value="@if(strlen(old('ext')) > 0){{old('ext')}}@elseif(isset($lastInfo->phone_split[2])){{$lastInfo->phone_split[2]}}@else{!! '' !!}@endif">
                            <div class="errinfo"></div>
                        </li>
                        <li class="list l_number tip">
                            <span class="left"></span>
                            <i class="mustFillIn">*</i>手机号码与固定电话必须填写一项
                        </li>
                    </ul>
                    <button type="submit">发布兼职</button>
                </form>
            </div>
        </div>
    </div>
    {{--职位信息及侧边下载框结束--}}
@endsection
{{--兼职详情页js--}}
@section('footerjs')
    @parent
    <script type="text/javascript" src="{{Resources::jsOption('part_time')}}"></script>

    <!--地区三级联动-->
    <script type="text/javascript" src="{{asset('/default/js/jquery/jquery.select.area.js')}}"></script>
    {{--工作地区--}}
    <script type="text/javascript" src="{{asset('/default/js/jquery/jquery.area.js')}}"></script>
    <!--jedate时间-->
    <script type="text/javascript" src="{{asset('/default/js/jquery/jquery.jedate.js')}}"></script>

    <!--选择地图定位map-->
    <div id="twobox_sceen" class="twobox_sceen"></div>
    <script type="text/javascript" src="{{asset('/default/js/company/setmap.js')}}"></script>

    <!--表单校验-->
    <script type="text/javascript" src="{{asset('/default/js/jquery/jquery.validate.extend.js')}}"></script>
    <script type="text/javascript" src="{{asset('/default/js/part_time/part_time_form.js')}}"></script>

    <script>
        var iframeMapUrl = "{{ url('company/iframe_map') }}";
        var allClickStatus = 0;
        var canChangeAllClickCount = 0;
        $(function () {
            //循环获取是否已全选状态
            for (var i = 0; i < 21; i++) {
                var numValue = $('.numValue').eq(i).attr('value');
                if (numValue == 1) {
                    canChangeAllClickCount++;
                }
            }
            if (canChangeAllClickCount == 21) {
                allClickStatus = 1;
                $('#allCheck').html('取消全选');
            }

            //侧边导航栏点击事件
            $('.main .wrapper .asideNav ul').on('click.asideNav', 'li', function () {
                var url = $(this).attr('data-href');
                window.location.href = url;
            });
            //兼职类型
            var selectPartTimeType = $("#partTimeType").select({
                defaults: null,//默认按索引选中null为不选
                defaultFill: [{"value": '', "text": "请选择"}],//当defaults为null时,填空使用这个
                optionData: option_part_time_type
                {{--selected:'{{old('type_id')}}'--}}
            });
            //性别要求
            var sex = $("#sex").select({
                defaults: null,//默认按索引选中null为不选
                defaultFill: [{"value": '', "text": "请选择"}],//当defaults为null时,填空使用这个
                optionData: [
                    {"value": 0, "text": "不限"},
                    {"value": 1, "text": "男"},
                    {"value": 2, "text": "女"}
                ]
            });
            //教育要求
            option_education.unshift({"value": 0, "text": "不限"});
            var education = $("#education").select({
                defaults: null,//默认按索引选中null为不选
                defaultFill: [{"value": '', "text": "请选择"}],//当defaults为null时,填空使用这个
                optionData: option_education,
                {{--selected:'{{old('education')}}'--}}
            });
            //薪资结算单位
            var selectSalaryUnit = $("#salary_unit").select({
//                defaults: null,//默认按索引选中null为不选
//                defaultFill: [{"value": '', "text": "请选择"}],//当defaults为null时,填空使用这个
                optionData: option_part_time_salary_unit
                {{--selected:'{{old('salary_unit')}}'--}}
            });
            //薪资结算方式
            var selectSalaryMethod = $("#salary_method").select({
//                defaults: null,//默认按索引选中null为不选
//                defaultFill: [{"value": '', "text": "请选择"}],//当defaults为null时,填空使用这个
                optionData: option_part_time_salary_method
                {{--selected:'{{old('salary_method')}}'--}}
            });
            //时间选择
            var start = {
                format: 'YYYY-MM-DD',
                minDate: $.nowDate(0), //设定最小日期为当前日期
                festival: false,
                skinCell: "jedateInter",
                //isinitVal:true,
                maxDate: '2099-06-16 23:59:59', //最大日期
                fixed: true
            };
            $("#inputTimeStart").jeDate(start);
            $("#inputTimeEnd").jeDate(start);
            //页面加载时空闲时间选择
            var numValue = $('.numValue');
            for (i = 0; i < 21; i++) {
                var checked = numValue.eq(i).attr('value');
                var dateName = numValue.eq(i).attr('id');
                if (checked == 1) {
                    numValue.eq(i).next("[data-name='" + dateName + "']").attr('checked', true);
                    numChange('checked', dateName);
                }
            }
            //页面加载时是否长期兼职选择控制
            var longTerm = $('#longTerm').attr('value');
            if (longTerm == 1) {
                $('#longTermValue').attr('checked', true);
                longTermChange('checked');
            }
        });
        //空闲时间选择
        $('.num').click(function () {
            var checked = $(this).attr('checked');
            var dateName = $(this).attr('data-name');
            numChange(checked, dateName);
        });
        function numChange(checked, dateName) {
            if (checked === 'checked') {
                $('#' + dateName).attr('value', 1);
            } else {
                $('#' + dateName).attr('value', 0);
            }
        }

        //全选取消全选操作
        $('#allCheck').click(function () {
            if (allClickStatus == 0) {
                allClickStatus = 1;
                $('.numValue').attr('value', 1);
                $('.num').attr('checked', true);
                $(this).html('取消全选');
            } else {
                allClickStatus = 0;
                $('.numValue').attr('value', 0);
                $('.num').attr('checked', false);
                $(this).html('全选');
            }
        });

        //是否长期兼职选择控制
        $('#longTermValue').click(function () {
            var checked = $(this).attr('checked');
            longTermChange(checked);
        });
        function longTermChange(checked) {
            if (checked === 'checked') {
                $('#longTerm').attr('value', 1);
                $('#inputTimeStart').attr('value', '').attr('disabled', true).attr('disabled', true);
                $('#inputTimeEnd').attr('value', '').attr('disabled', true).attr('disabled', true);
            } else {
                $('#longTerm').attr('value', 0);
                $('#inputTimeStart').attr('disabled', false);
                $('#inputTimeEnd').attr('disabled', false);
            }
        }
        //弹窗地址选择
        function workplaceInput2(randfrm){
            var workarr = {
                objId: '#jobLoc' + randfrm,					//当前显示内容的ID值
                objProvince: 'address_P' + randfrm,	        //当前select省份
                objCity: 'address_C' + randfrm,		        //当前select市区县
                objCate: '#locCate' + randfrm,					//当前页面弹出层显示要追加的工作地区类别内容
                objTwoCate: '#twolocCate' + randfrm,		    //当前页面要追加的工作地区类别内容
                objChcekbox: '#jobLocations' + randfrm,	    //当前弹出层 复选框checkbox的前缀名id值
                objSelect: 'locSelect' + randfrm,				//当前弹出层 追加到弹出要追加的内容里面的ID前缀值
                objTwoSelect: 'twolocSelect' + randfrm,	    //当前页面  追加到当前页面要追加的内容里面的ID前缀值
                objPostCate: '#workplace',					//当前页面  追加到当前页面input要追加的内容里面的ID前缀值
                objArr: ["#city_id" + randfrm], //当前隐藏表单
                keep_sceen: '#keep_sceen',					//遮掩层
                objLevel: '3',								//设置当前显示的级别
                objInpaLength: '1'							//设置当前input 表单选项的个数
            };
            workObj.showextend(randfrm, workarr);
        }
    </script>
@endsection